package com.shinewind.home.controller;

import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.shinewind.common.constant.messageConstant;
import com.shinewind.home.service.IBrandService;
import com.shinewind.pojo.entity.Brand;
import com.shinewind.pojo.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/index")
@Api(value = "模型品牌接口", description = "用于实现模型品牌操作")
public class BrandController {
    @Autowired
    private IBrandService iBrandService;

    @GetMapping("/model/brand/{bId}")
    @ApiOperation(value = "按模型id查询单个模型品牌信息", notes = "按id查询", response = Result.class)
    public Result getBrandInfoById(@PathVariable("bId") Integer bId){
        Brand brand = iBrandService.getBrandInfoById(bId);
        return Result.success(brand.getBrand(), BooleanUtil.isTrue(ObjectUtil.isNotNull(brand)),
                messageConstant.QUERY_SUCCESS);
    }
}